package com.ruoyi.manager.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manager.domain.TbeduWeekscore;
import com.ruoyi.manager.service.ITbeduWeekscoreService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生周考核Controller
 * 
 * @author L1hao
 * @date 2021-09-16
 */
@Controller
@RequestMapping("/manager/weekscore")
public class TbeduWeekscoreController extends BaseController
{
    private String prefix = "manager/weekscore";

    @Autowired
    private ITbeduWeekscoreService tbeduWeekscoreService;

    @RequiresPermissions("manager:weekscore:view")
    @GetMapping()
    public String weekscore()
    {
        return prefix + "/weekscore";
    }

    /**
     * 查询学生周考核列表
     */
    @RequiresPermissions("manager:weekscore:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbeduWeekscore tbeduWeekscore)
    {
        startPage();
        List<TbeduWeekscore> list = tbeduWeekscoreService.selectTbeduWeekscoreList(tbeduWeekscore);
        return getDataTable(list);
    }

    /**
     * 导出学生周考核列表
     */
    @RequiresPermissions("manager:weekscore:export")
    @Log(title = "学生周考核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbeduWeekscore tbeduWeekscore)
    {
        List<TbeduWeekscore> list = tbeduWeekscoreService.selectTbeduWeekscoreList(tbeduWeekscore);
        ExcelUtil<TbeduWeekscore> util = new ExcelUtil<TbeduWeekscore>(TbeduWeekscore.class);
        return util.exportExcel(list, "学生周考核数据");
    }

    /**
     * 新增学生周考核
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存学生周考核
     */
    @RequiresPermissions("manager:weekscore:add")
    @Log(title = "学生周考核", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbeduWeekscore tbeduWeekscore)
    {
        return toAjax(tbeduWeekscoreService.insertTbeduWeekscore(tbeduWeekscore));
    }

    /**
     * 修改学生周考核
     */
    @GetMapping("/edit/{fId}")
    public String edit(@PathVariable("fId") Long fId, ModelMap mmap)
    {
        TbeduWeekscore tbeduWeekscore = tbeduWeekscoreService.selectTbeduWeekscoreByFId(fId);
        mmap.put("tbeduWeekscore", tbeduWeekscore);
        return prefix + "/edit";
    }

    /**
     * 修改保存学生周考核
     */
    @RequiresPermissions("manager:weekscore:edit")
    @Log(title = "学生周考核", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbeduWeekscore tbeduWeekscore)
    {
        return toAjax(tbeduWeekscoreService.updateTbeduWeekscore(tbeduWeekscore));
    }

    /**
     * 删除学生周考核
     */
    @RequiresPermissions("manager:weekscore:remove")
    @Log(title = "学生周考核", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbeduWeekscoreService.deleteTbeduWeekscoreByFIds(ids));
    }
}
